package br.com.finantech;

import java.util.ArrayList;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

public class CategoriasAdapter extends ArrayAdapter<Categoria> {
	private ArrayList<Categoria> categorias;
	Context context;

	public CategoriasAdapter(Context context, int textViewResourceId, ArrayList<Categoria> categorias) {
		super(context, textViewResourceId, categorias);
		this.categorias = categorias;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		View v = convertView;
		if (v == null) {
			LayoutInflater vi = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
			v = vi.inflate(R.layout.list_categoria, null);
		}

		Categoria categoria = this.categorias.get(position);
		if (categoria != null) {
			TextView nome_categoria = (TextView) v.findViewById(R.id.nome_categoria);
			nome_categoria.setText(categoria.nome);
		}
		return v;
	}
}